﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Channels;

namespace BilingualSentIndexing
{
    public class FaultErrorHandler : IErrorHandler
    {
        public bool HandleError(Exception error)
        {
            CommunicationException fe = error as CommunicationException;

            if (fe != null)
            {
                System.Diagnostics.EventLog.WriteEntry("Bilingual Sentence Search Indexing Service Exception", "Communication Exception:\nMessage:" + fe.Message + "\n-----------\nInner Exception:" + fe.InnerException.ToString() + "\n------------\nSource: " + fe.Source + "\n------------\nStack Trace:" + fe.StackTrace + "\n-----------\nTargetSite" + fe.TargetSite.ToString());
            }
            else
            {
                System.Diagnostics.EventLog.WriteEntry("Bilingual Sentence Search Indexing Service Exception", "Uncaught Exception\nMessage:\n" + error.Message + "\n---------------\nSource:" + error.Source + "\n-------------\nStack Trace:" + error.StackTrace);
            }
            return false;
        }

        public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault)
        {
          
        }
    }
}
